home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / kbdread.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  728 b   |  37 lines

  1. /*
  2. ** kbdread.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include <dos.h>
  9. #include "pictor.h"
  10.  
  11. int _PL_pushedkey = 0;
  12. int _PL_escape = FALSE;
  13.  
  14. /*
  15. ** Returns the next available keystroke with the ASCII character
  16. ** in the low byte and the scan code in the high byte.
  17. */
  18. int kbdread(void)
  19. {
  20.     union REGS regs;
  21.  
  22.     if(_PL_pushedkey != 0) {
  23.         regs.x.ax = _PL_pushedkey;
  24.         _PL_pushedkey = 0;
  25.     }
  26.     else {
  27.         regs.h.ah = 0x00;
  28.         int86(0x16,®s,®s);
  29.         if(regs.x.ax == 0x0000)  /* ctrl-break */
  30.             regs.x.ax = 0xFFFF;
  31.     }
  32.     /* indicate if last key read was escape */
  33.     _PL_escape = (regs.x.ax == ESCAPE_KEY);
  34.     return(regs.x.ax);
  35.  
  36. } /* kbdread */
  37.